

import DataBaseManager.DataBase;
import DataBaseManager.Field;
import DataBaseManager.Table;
import DataType.MyDataType;

public class test {
	public static void main(String[] args) {
		DataBase data = new DataBase("dfs");
		Table table = new Table("HocSinh");
		table.getFields().add(new Field("Mssv",MyDataType.MY_TYPE.MY_NUMBERIC));
		table.getFields().add(new Field("lop",MyDataType.MY_TYPE.MY_NUMBERIC));
		table.getFields().add(new Field("HoTen",MyDataType.MY_TYPE.MY_STRING));
		table.getFields().add(new Field("Toan",MyDataType.MY_TYPE.MY_NUMBERIC));
		table.getFields().add(new Field("Van",MyDataType.MY_TYPE.MY_NUMBERIC));
		
		
		Table tablelop = new Table("Lop");
		tablelop.getFields().add(new Field("lop",MyDataType.MY_TYPE.MY_NUMBERIC));
		tablelop.getFields().add(new Field("truong",MyDataType.MY_TYPE.MY_NUMBERIC));
		tablelop.getFields().add(new Field("TenLop",MyDataType.MY_TYPE.MY_STRING));

		Table tabletruong = new Table("Truong");
		tabletruong.getFields().add(new Field("matruong",MyDataType.MY_TYPE.MY_NUMBERIC));
		tabletruong.getFields().add(new Field("TenTruong",MyDataType.MY_TYPE.MY_STRING));
		
		data.addTable(table);
		data.addTable(tablelop);
		data.addTable(tabletruong);
		
		Query query = new Query(data);
		
		query.execQuery(" inSert inTo HocSinh values(0, 0,  'hg' , 2, 3.5  )");
		query.execQuery(" inSert inTo HocSinh(Mssv, HoTen, Toan,Van,lop ) values(1,'ku' , 5, 3.5 ,2 )");
		query.execQuery(" inSert inTo HocSinh(MSsv,HoTen, Van,lop  )values(2, 'abc' , 2.5 ,0 )");
		query.execQuery(" inSert inTo HocSinh values(3,1, 'a' , 5.5,  5.5  )");
		query.execQuery(" inSert inTo HocSinh values(4,0, 'a' , 5.5 ,6)");
		query.execQuery(" inSert inTo HocSinh values(5,1,'gh', 1 , 2 )");
	
		query.execQuery(" inSert inTo Lop values(0,0, '10a1' )");
		query.execQuery(" inSert inTo Lop values(1,0,'10a2' )");
		query.execQuery(" inSert inTo Lop values(2,1,'10ku')");
		
		query.execQuery(" inSert inTo TRuong values(0,'aaaaaaaaaaa' )");
		query.execQuery(" inSert inTo TRuong values(1,'bbbbbbbbbbb')");
		
		/*table.Print();
		tablelop.Print();
		//query.nonQuery(" update HocSinh set Van = 0 where (toan>5)or(van < 5)");	
		//query.nonQuery(" delete from Table where" );
		//		"where ((Toan = Van) or  ((Van = 3.5)and hoTen = 'ku' and (Toan = 5.5)))");
		//query.nonQuery(" delete from Table " 
		//+"where (Toan <= 5) or not(van > 5 and van <> 5.5)"  );
		//query.nonQuery(" delete from Table where ((1=1 and(f1 == 5)))");

		table.Print();
		query.execQuery("select van,Hoten,toan,Van,lop.tenlop from HocSinh,Lop where lop.lop = hocsinh.lop");
		
		/*
		query.selectQuery(
				"select van,Hoten,toan,Van,lop.tenlop from HocSinh,Lop where lop.lop = hocsinh.lop"
				).Print();
		query.selectQuery(
				"select * \nfrom HocSinh hs,Lop,truong  where lop.lop = hs.lop and (truong = matruong)"
				).Print();
		query.selectQuery(
				"select *,count(toan),avg(van) from HocSinh hs,lop where hs.lop = lop.lop group by truong,lop.lop having avg(van) < 4"
				).Print();
		query.selectQuery(
				"select *,max(toan),min(van),avg(toan),avg(van) from HocSinh group by lop having avg(toan) < avg(van)"
				).Print();
*/
	}

}
